package com.xrit.controller;

import com.xrit.constant.MessageConstant;
import com.xrit.pojo.CheckGroup;
import com.xrit.result.Result;
import org.springframework.security.core.context.SecurityContextHolder;
import org.springframework.security.core.userdetails.User;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

import static org.apache.ibatis.ognl.DynamicSubscript.all;

@RestController
@RequestMapping("user")
public class UserController {

    @RequestMapping("/getUserName.do")
    public Result getUserName(){
        //1.获取认证对象
        User principal = (User) SecurityContextHolder.getContext().getAuthentication().getPrincipal();
        //2.获取用户名
        String username = principal.getUsername();
        return new Result(true, MessageConstant.QUERY_CHECKGROUP_FAIL,username);
    }
}
